﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NJL.Web.AdminVisitor
{
    public partial class OrderDetails : BasePage
    {
        private readonly NJL.BLL.NJL_BOOK_ORDER bllBookOrder = new BLL.NJL_BOOK_ORDER();
        private readonly NJL.BLL.NJL_BOOK bllBook = new BLL.NJL_BOOK();
        private readonly NJL.BLL.NJL_CS_BOOK_PAY bllBookPay = new BLL.NJL_CS_BOOK_PAY();
        private readonly NJL.BLL.NJL_ATTRACTION bllAttr = new BLL.NJL_ATTRACTION();
        private readonly NJL.BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
        protected NJL.Model.NJL_BOOK_ORDER modelBookOrder;
        protected NJL.Model.NJL_BOOK modelBook;
        NJL.Model.NJL_CS_BOOK_PAY modelPay;
        protected NJL.Model.NJL_ATTRACTION modelAttr;
        protected NJL.Model.NJL_COMPANY modelCompany;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                modelBookOrder = bllBookOrder.GetModel(Request.QueryString["id"]);
                litOrderNumber.Text = modelBookOrder.ORDER_NO;                        //订单号
                litTicketNumber.Text = modelBookOrder.TICKET_COUNT.ToString();  //门票数量
                litTotlePrice.Text = string.Format("{0:0.00}", modelBookOrder.ORDER_TOTAL); //总价格
                litVISIT_DATE.Text = string.Format("{0:yyyy-MM-dd}", modelBookOrder.VISIT_DATE);  // 游玩时间
                litOrderCreatDate.Text = modelBookOrder.CREATE_DATE_TIME.ToString();       //下单时间
                litAddress.Text = "景区售票处";
                litPrice.Text = string.Format("{0:0.00}", modelBookOrder.BOOK_PRICE);
                modelBook = bllBook.GetModel(modelBookOrder.NJL_BOOK_ID);
                litBookName.Text = modelBook.BOOK_NAME;                              //预订类型
                litBackPrice.Text = string.Format("{0:0.00}", modelBook.BACK_PRICE); //返点金额

                litPickName.Text = modelBookOrder.PICK_NAME;                          //取票人姓名
                litPickPhone.Text = modelBookOrder.PICK_MOBILE;                       //取票人电话


                modelPay = bllBookPay.GetModel(modelBook.NJL_CS_BOOK_PAY_TYPE_CODE);
                litPayment.Text = modelPay.TYPE_NAME;                                 //支付方式
                if (modelBook.NJL_CS_BOOK_PAY_TYPE_CODE == "2")
                {
                    if (modelBookOrder.ORDER_STATE.ToString() == "1")
                    {
                        litOrderState.Text = "预订成功";
                    }
                }
                if (modelBook.NJL_CS_BOOK_PAY_TYPE_CODE == "1")
                {
                    if (modelBookOrder.ORDER_STATE == 1)
                    {
                        litOrderState.Text = "待支付状态";
                    }
                    else if (modelBookOrder.ORDER_STATE == 2)
                    {
                        litOrderState.Text = "支付成功";
                    }
                }
                if (modelBook.TYPE_CODE == "1")
                {
                    modelAttr = bllAttr.GetModel(modelBook.TARGET_ID);
                    litAttrName.Text = modelAttr.ATTRACTION_NAME;
                    litjdnjl.Text = "景点";
                }
                else if (modelBook.TYPE_CODE == "2")
                {
                    modelCompany = bllCompany.GetModel(modelBook.TARGET_ID);
                    litAttrName.Text = modelCompany.COMPANY_NAME;
                    litjdnjl.Text = "农家乐或度假山庄";
                }

            }

        }
    }
}